//
//  FuchuangContentView.m
//  AAIM
//
//  Created by 远的小布丁 on 2020/1/28.
//  Copyright © 2020 AAIM. All rights reserved.
//

#import "FuchuangContentView.h"

@implementation FuchuangContentView

-(instancetype)initWithFrame:(CGRect)frame withTitle:(NSString *)title withImg:(UIImage *)image{
    self = [super initWithFrame:frame];
    if (self) {
        self.headImg = [[UIImageView alloc]initWithFrame:CGRectMake(15, 12, 36, 36)];
        self.headImg.image = image;
        self.headImg.layer.cornerRadius = 18;
        self.headImg.layer.masksToBounds = YES;
        [self addSubview:self.headImg];
        self.titleLbl = [[UILabel alloc]initWithFrame:CGRectMake(self.headImg.right+7, 6, 153, 50)];
        self.titleLbl.numberOfLines = 2;
        self.titleLbl.centerY = 30;
        self.titleLbl.font = kMainFont(15);
        self.titleLbl.textColor = KHEXCOLOR(AllBackColor_titleColor);
        self.titleLbl.text = title;
        [self addSubview:self.titleLbl];
        self.closeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        self.closeBtn.frame = CGRectMake(self.titleLbl.right+7, 12, 36, 36);
        [self.closeBtn setImage:[UIImage imageNamed:@"弹窗的叉叉"] forState:UIControlStateNormal];
        [self.closeBtn addTarget:self action:@selector(closeFuChuangActive:) forControlEvents:UIControlEventTouchUpInside];
        [self.closeBtn setBackgroundColor:[UIColor clearColor]];
        [self addSubview:self.closeBtn];
        self.openUrlBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        self.openUrlBtn.frame = CGRectMake(0, 0, 211, self.height);
        [self.openUrlBtn addTarget:self action:@selector(openUrlActive:) forControlEvents:UIControlEventTouchUpInside];
        [self.openUrlBtn setBackgroundColor:[UIColor clearColor]];
        [self addSubview:self.openUrlBtn];
    }
    return self;
}

- (void)openUrlActive:(UIButton *)sender{
    if ([self.delegate respondsToSelector:@selector(openUrlTouchActive:)]) {
        [self.delegate openUrlTouchActive:sender];
    }
}

- (void)closeFuChuangActive:(UIButton *)sender{
    if ([self.delegate respondsToSelector:@selector(closerFuChuang:)]) {
        [self.delegate closerFuChuang:sender];
    }
}

@end
